<?php
    $sql = "SELECT * FROM sach";
    $result = DataProvider::ExecuteQuery($sql);
    $i = 1;
?>

<div class="row-fluid">

    <div class="span12">
        <div class="head">
            <div class="isw-grid"></div>
            <h1>Các Đầu Sách</h1>
            <ul class="buttons" onclick="location = 'index.php?sach=3&id=<?php echo $row["MaSach"] ?>';">
                <li>
                    <a href="#" class="isw-plus"></a>
                    <ul class="dd-list">
                        <li><a href="#"><span class="isw-plus"></span>Thêm Sách</a></li>
                    </ul>
                </li>
            </ul>
            <div class="clear"></div>
        </div>
        <div class="block-fluid table-sorting">
            <table cellpadding="0" cellspacing="0"  class="table" id="tSortable">
                <thead>
                    <tr>
                        <th width="20%">Tên Sách</th>
                        <th width="20%">Tác Giả</th>
                        <th width="20%">Thể Loại</th>
                        <th width="20%">Nhà Xuất Bản</th>
                        <th width="7%">Xử Lý</th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                        while($row = mysql_fetch_array($result))
                        {
                    ?>
                    <tr>
                        <td><?php echo $row["TenSach"]; ?></td>
                        <td><?php echo $row["TacGia"]; ?></td>
                        <td>
                            <?php
                                $sql1 = "SELECT * FROM loaisach WHERE BiXoa=0 AND MaLoaiSach = '{$row["MaLoaiSach"]}'";
                                $result1 = DataProvider::ExecuteQuery($sql1);
                                $row1 = mysql_fetch_array($result1);
                                echo $row1["TenLoaiSach"];
                            ?>
                        </td>
                        <td>
                            <?php
                                $sql2 = "SELECT * FROM nxb WHERE BiXoa=0 AND MaNXB = '{$row["MaNXB"]}'";
                                $result2 = DataProvider::ExecuteQuery($sql2);
                                $row2 = mysql_fetch_array($result2);
                                echo $row2["TenNXB"];
                            ?>
                        </td>


                        <td>
                            <button class="btn btn-info" onclick="location = 'index.php?sach=4&id=<?php echo $row["MaSach"] ?>';" type="button">Chi Tiết</button>

                        </td>


                    </tr>

                    <?php
                        }
                    ?>

                </tbody>
            </table>
            <div class="clear"></div>
        </div>

    </div>

</div>

            <div class="dr"><span></span></div>